<template>
	<view>
		<view class="u-m-t-20">
			<u-cell-group>
				<u-cell-item title="退出登录" @click="goLogout()"></u-cell-item>
			</u-cell-group>
		</view>
	</view>
</template>

<script>
	import { mapState, mapGetters, mapActions } from 'vuex'
	export default {
		data() {
			return {
				userId: 0
			}
		},
		computed: {
			...mapGetters(['isLogin']),
			...mapState(['loginInfo', 'userInfo'])
		},
		async onLoad() {
			await this.updateUserInfo()
			this.userId = this.userInfo.id
		},
		methods: {
			...mapActions(['loginAction', 'updateUserInfo', 'logout']),
			async goLogout() {
				await this.logout()
				const message = {
					cmd: 12,
					user_id: this.userId
				}
				this.$ws.sendMessage(message)
				this.$ws.closeConnect()
				setTimeout(() => {
					this.$u.route({
						url: 'pages/auth/login/login',
						type: 'reLaunch'
					})
				}, 1000)
			}
		}
	}
</script>

<style lang="scss">
page{
	background-color: #ededed;
}
</style>
